package com.xuecheng.content.controller;

import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author achao
 * @version 1.0
 */
@Slf4j
@Api(value = "课程老师相关接口",tags = "课程老师相关接口")
@RestController
@RequestMapping("/courseTeacher")
public class CourseTeacherController {

    @Autowired
    private CourseTeacherService courseTeacherService;

    @GetMapping("/list/{courseId}")
    public List<CourseTeacher> getCourseTeachersByCourseId(@PathVariable("courseId") Long courseId){
        return courseTeacherService.getCourseTeachersByCourseId(courseId);
    }

    @PostMapping
    public CourseTeacher saveCourseTeacher(@RequestBody CourseTeacher courseTeacher) {
       courseTeacherService.save(courseTeacher);
       return courseTeacher;
    }

    @DeleteMapping("/course/{courseId}/{teacherId}")
    public void deleteCourseTeacher(@PathVariable("courseId") Long courseId, @PathVariable("teacherId") Long teacherId) {
        courseTeacherService.deleteCourseTeacher(courseId, teacherId);
    }

}
